package tum0r.cryptology.encryption;

import tum0r.misc.StringUtils;

/**
 * 工程: JavaTools<br>
 * 包: tum0r.cryptology.encryption<br>
 * 创建者: tum0r<br>
 * 创建时间: 2020/8/22 20:20<br>
 * <br>
 */
public class RailFenceEncryption {
    public String encryption(String plainText, int num) {
        StringBuilder stringBuilder = new StringBuilder();
        if (!StringUtils.isNullOrEmptyOrSpace(plainText) && num > 1) {
            char[] temp = plainText.toCharArray();
            for (int count = 0; count < num; count++) {
                for (int now = count; now < temp.length; now += num) {
                    stringBuilder.append(temp[now]);
                }
            }
        }
        return stringBuilder.toString();
    }
}
